<script setup>
import {onMounted, ref} from "vue";
import {all as allRole} from "@/apis/sys/role.js";

const modelValue = defineModel('value')
onMounted(() => {
  // 加载角色列表
  loadRoleList()
})
const props = defineProps({
  disabled: {
    type: Boolean,
    default: false
  },
  multiple: {
    type: Boolean,
    default: false
  }
})
const roleList = ref([])
const loadRoleList = async () => {
  const {code, data} = await allRole()
  if (code === 0) {
    roleList.value = data
  }
}
</script>

<template>
  <n-select :options="roleList"
            label-field="name"
            value-field="id"
            clearable
            :multiple="props.multiple"
            v-model:value="modelValue"
            :disabled="props.disabled"/>
</template>

<style scoped>

</style>